import java.lang.Thread;
import java.net.*;
import java.io.*;

/**
 * 
 * @author Jesse en Jeroen
 *
 */
public class Service extends Thread{
	private Socket client;
	private Response res;
	private Servlet servlet;
	private Request req;
	private String documentRoot;
	
	public Service(Socket client, String documentRoot)
	{
		this.client = client;
		this.documentRoot = documentRoot;
	}
	
	public void close()
	{	
		try
		{
			client.close();
		}
		catch(IOException io)
		{
			
		}
	}
	
	public void run()
	{
		req = new Request(client);
		res = new Response(client);
		servlet = new Servlet(req, res, documentRoot);
		res.send();
		System.out.println("Closing this Socket");
		this.close();
	}
}
